<h2>Why is this an issue?</h2>
<p>When optional parameter values are not passed to base method calls, the value passed in by the caller is ignored. This can cause the function to
behave differently than expected, leading to errors and making the code difficult to debug.</p>
<h2>How to fix it</h2>
<h3>Code examples</h3>
<h4>Noncompliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
Public Class BaseClass
    Public Overridable Sub MyMethod(ByVal Optional i As Integer = 1)
        Console.WriteLine(i)
    End Sub
End Class

Public Class DerivedClass
    Inherits BaseClass

    Public Overrides Sub MyMethod(ByVal Optional i As Integer = 1)
        ' ...
        MyBase.MyMethod() ' Noncompliant: caller's value is ignored
    End Sub

    Private Shared Function Main(ByVal args As String()) As Integer
        Dim dc As DerivedClass = New DerivedClass()
        dc.MyMethod(12) ' prints 1
    End Function
End Class
</pre>
<h4>Compliant solution</h4>
<pre data-diff-id="1" data-diff-type="compliant">
Public Class BaseClass
    Public Overridable Sub MyMethod(ByVal Optional i As Integer = 1)
        Console.WriteLine(i)
    End Sub
End Class

Public Class DerivedClass
    Inherits BaseClass

    Public Overrides Sub MyMethod(ByVal Optional i As Integer = 1)
        ' ...
        MyBase.MyMethod(i)
    End Sub

    Private Shared Function Main(ByVal args As String()) As Integer
        Dim dc As DerivedClass = New DerivedClass()
        dc.MyMethod(12) ' prints 12
    End Function
End Class
</pre>
<h2>Resources</h2>
<h3>Documentation</h3>
<p>Microsoft Learn - <a
href="https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/procedures/optional-parameters">Optional Arguments
(Visual Basic)</a></p>

